﻿Option Explicit On
Option Compare Text
Imports System.Data.SqlClient
Imports CommonUtils






Public MustInherit Class genExplanations

#Region " Private Vars Generated Code "

    Private lExplanationID As Int32 = Int32.MinValue
    Private lExplanationText As String = ""

#End Region

#Region " Properties Generated Code "

    Public Property ExplanationID() As Int32
        Get
            Return lExplanationID
        End Get
        Set(ByVal value As Int32)
            lExplanationID = value
        End Set
    End Property

    Public Property ExplanationText() As String
        Get
            Return lExplanationText
        End Get
        Set(ByVal value As String)
            lExplanationText = value
        End Set
    End Property

#End Region

#Region " Methods Generated Code "

    Public Overridable Sub Reset()

        ExplanationID = Int32.MinValue
        ExplanationText = ""

    End Sub

    Public Sub New()
        'Don't do the select, as it is not needed.
    End Sub

    Public Sub New(ByVal aExplanationID As Int32)
        Construct(aExplanationID)
    End Sub

    Public Overridable Sub Construct(ByVal aExplanationID As Int32)
        Reset()
        Dim sSpName As String = "spExplanationSel"
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim lData As DataSet
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        sqlExplanationID.Value = aExplanationID

        lData = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, sSpName, sqlExplanationID)
        If (lData.Tables.Count > 0) Then
            If (lData.Tables(0).Rows.Count = 1) Then
                'Hydrate this object from the database.
                If Not lData.Tables(0).Rows(0)("ExplanationID") Is System.Dbnull.Value Then
                    lExplanationID = lData.Tables(0).Rows(0)("ExplanationID")
                End If
                If Not lData.Tables(0).Rows(0)("ExplanationText") Is System.Dbnull.Value Then
                    lExplanationText = lData.Tables(0).Rows(0)("ExplanationText")
                End If
            End If
        End If
    End Sub

    Public Overridable Function Save() As Int32
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        Dim sqlExplanationText As SqlParameter = New SqlParameter("@ExplanationText", SqlDbType.NVarChar)
        Dim sSPName As String
        sSPName = "spExplanationInsUpd"
        If ExplanationID <> Int32.MinValue Then
            sqlExplanationID.Value = ExplanationID
        Else
            sqlExplanationID.Value = System.DBNull.Value
        End If
        If ExplanationText <> "" Then
            sqlExplanationText.Value = ExplanationText
        Else
            sqlExplanationText.Value = System.DBNull.Value
        End If
        Dim sConn As String = TheSettings.SQLConnectionString
        ExplanationID = SqlHelper.ExecuteScalar(sConn, CommandType.StoredProcedure, sSPName, sqlExplanationID, sqlExplanationText)
        Return ExplanationID

    End Function

    Public Overridable Function Delete() As Integer
        Dim sSPName As String = "spExplanationDel"
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        If ExplanationID <> Int32.MinValue Then
            sqlExplanationID.Value = ExplanationID
        Else
            sqlExplanationID.Value = System.DBNull.Value
        End If

        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, sSpName, sqlExplanationID)
        Return iRet
    End Function

    Public Overridable Function List() As DataTable
        Dim dTable As DataTable
        Dim sSpName As String = "spExplanationSelAll"
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dSet As DataSet
        dSet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, sSpName)
        dTable = dSet.Tables(0)
        Return dTable
    End Function

    Public Overridable Function ListByExplanationText(ByVal aExplanationText As String) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "spExplanationSelByExplanationText"
        Dim sqlExplanationText As SqlParameter = New SqlParameter("@ExplanationText", SqlDbType.NVarChar)
        sqlExplanationText.Value = aExplanationText
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sqlExplanationText)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

    Public Overridable Function ListByExplanationID(ByVal aExplanationID As Int32) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "spExplanationSelByExplanationID"
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        sqlExplanationID.Value = aExplanationID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sqlExplanationID)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

    Public Overridable Function DeleteByExplanationText(ByVal aExplanationText As String) As Integer
        Dim spName As String = "spExplanationDelByExplanationText"
        Dim sqlExplanationText As SqlParameter = New SqlParameter("@ExplanationText", SqlDbType.NVarChar)
        sqlExplanationText.Value = aExplanationText
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, spName, sqlExplanationText)
        Return iRet
    End Function

    Public Overridable Function DeleteByExplanationID(ByVal aExplanationID As Int32) As Integer
        Dim spName As String = "spExplanationDelByExplanationID"
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        sqlExplanationID.Value = aExplanationID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, spName, sqlExplanationID)
        Return iRet
    End Function

    Public Overridable Function ListDynamic(ByVal aWhereCondition As String, ByVal aOrderByExpression As String) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "[dbo].[spExplanationSelDyn]"
        Dim sWhere As SqlParameter = New SqlParameter("@WhereCondition", SqlDbType.NVarChar, 500)
        Dim sOrder As SqlParameter = New SqlParameter("@OrderByExpression", SqlDbType.NVarChar, 250)
        sWhere.Value = aWhereCondition
        sOrder.Value = aOrderByExpression
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sWhere, sOrder)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

#End Region

End Class






Public MustInherit Class genFlashCards

#Region " Private Vars Generated Code "

    Private lFlashCardID As Int32 = Int32.MinValue
    Private lExplanationID As Int32 = Int32.MinValue
    Private lSuggestedActionID As Int32 = Int32.MinValue
    Private lDealersUpCard As String = ""
    Private lPlayersHand As String = ""
    Private lToughHand As Boolean = False

#End Region

#Region " Properties Generated Code "

    Public Property FlashCardID() As Int32
        Get
            Return lFlashCardID
        End Get
        Set(ByVal value As Int32)
            lFlashCardID = value
        End Set
    End Property

    Public Property ExplanationID() As Int32
        Get
            Return lExplanationID
        End Get
        Set(ByVal value As Int32)
            lExplanationID = value
        End Set
    End Property

    Public Property SuggestedActionID() As Int32
        Get
            Return lSuggestedActionID
        End Get
        Set(ByVal value As Int32)
            lSuggestedActionID = value
        End Set
    End Property

    Public Property DealersUpCard() As String
        Get
            Return lDealersUpCard
        End Get
        Set(ByVal value As String)
            lDealersUpCard = value
        End Set
    End Property

    Public Property PlayersHand() As String
        Get
            Return lPlayersHand
        End Get
        Set(ByVal value As String)
            lPlayersHand = value
        End Set
    End Property

    Public Property ToughHand() As Boolean
        Get
            Return lToughHand
        End Get
        Set(ByVal value As Boolean)
            lToughHand = value
        End Set
    End Property

#End Region

#Region " Methods Generated Code "

    Public Overridable Sub Reset()

        FlashCardID = Int32.MinValue
        ExplanationID = Int32.MinValue
        SuggestedActionID = Int32.MinValue
        DealersUpCard = ""
        PlayersHand = ""
        ToughHand = False

    End Sub

    Public Sub New()
        'Don't do the select, as it is not needed.
    End Sub

    Public Sub New(ByVal aFlashCardID As Int32)
        Construct(aFlashCardID)
    End Sub

    Public Overridable Sub Construct(ByVal aFlashCardID As Int32)
        Reset()
        Dim sSpName As String = "spFlashCardSel"
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim lData As DataSet
        Dim sqlFlashCardID As SqlParameter = New SqlParameter("@FlashCardID", SqlDbType.Int)
        sqlFlashCardID.Value = aFlashCardID

        lData = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, sSpName, sqlFlashCardID)
        If (lData.Tables.Count > 0) Then
            If (lData.Tables(0).Rows.Count = 1) Then
                'Hydrate this object from the database.
                If Not lData.Tables(0).Rows(0)("FlashCardID") Is System.Dbnull.Value Then
                    lFlashCardID = lData.Tables(0).Rows(0)("FlashCardID")
                End If
                If Not lData.Tables(0).Rows(0)("ExplanationID") Is System.Dbnull.Value Then
                    lExplanationID = lData.Tables(0).Rows(0)("ExplanationID")
                End If
                If Not lData.Tables(0).Rows(0)("SuggestedActionID") Is System.Dbnull.Value Then
                    lSuggestedActionID = lData.Tables(0).Rows(0)("SuggestedActionID")
                End If
                If Not lData.Tables(0).Rows(0)("DealersUpCard") Is System.Dbnull.Value Then
                    lDealersUpCard = lData.Tables(0).Rows(0)("DealersUpCard")
                End If
                If Not lData.Tables(0).Rows(0)("PlayersHand") Is System.Dbnull.Value Then
                    lPlayersHand = lData.Tables(0).Rows(0)("PlayersHand")
                End If
                If Not lData.Tables(0).Rows(0)("ToughHand") Is System.Dbnull.Value Then
                    lToughHand = lData.Tables(0).Rows(0)("ToughHand")
                End If
            End If
        End If
    End Sub

    Public Overridable Function Save() As Int32
        Dim sqlFlashCardID As SqlParameter = New SqlParameter("@FlashCardID", SqlDbType.Int)
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        Dim sqlSuggestedActionID As SqlParameter = New SqlParameter("@SuggestedActionID", SqlDbType.Int)
        Dim sqlDealersUpCard As SqlParameter = New SqlParameter("@DealersUpCard", SqlDbType.NVarChar)
        Dim sqlPlayersHand As SqlParameter = New SqlParameter("@PlayersHand", SqlDbType.NVarChar)
        Dim sqlToughHand As SqlParameter = New SqlParameter("@ToughHand", SqlDbType.Bit)
        Dim sSPName As String
        sSPName = "spFlashCardInsUpd"
        If FlashCardID <> Int32.MinValue Then
            sqlFlashCardID.Value = FlashCardID
        Else
            sqlFlashCardID.Value = System.DBNull.Value
        End If
        If ExplanationID <> Int32.MinValue Then
            sqlExplanationID.Value = ExplanationID
        Else
            sqlExplanationID.Value = System.DBNull.Value
        End If
        If SuggestedActionID <> Int32.MinValue Then
            sqlSuggestedActionID.Value = SuggestedActionID
        Else
            sqlSuggestedActionID.Value = System.DBNull.Value
        End If
        If DealersUpCard <> "" Then
            sqlDealersUpCard.Value = DealersUpCard
        Else
            sqlDealersUpCard.Value = System.DBNull.Value
        End If
        If PlayersHand <> "" Then
            sqlPlayersHand.Value = PlayersHand
        Else
            sqlPlayersHand.Value = System.DBNull.Value
        End If
        sqlToughHand.Value = ToughHand
        Dim sConn As String = TheSettings.SQLConnectionString
        FlashCardID = SqlHelper.ExecuteScalar(sConn, CommandType.StoredProcedure, sSPName, sqlFlashCardID, sqlExplanationID, sqlSuggestedActionID, sqlDealersUpCard, sqlPlayersHand, sqlToughHand)
        Return FlashCardID

    End Function

    Public Overridable Function Delete() As Integer
        Dim sSPName As String = "spFlashCardDel"
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim sqlFlashCardID As SqlParameter = New SqlParameter("@FlashCardID", SqlDbType.Int)
        If FlashCardID <> Int32.MinValue Then
            sqlFlashCardID.Value = FlashCardID
        Else
            sqlFlashCardID.Value = System.DBNull.Value
        End If

        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, sSpName, sqlFlashCardID)
        Return iRet
    End Function

    Public Overridable Function List() As DataTable
        Dim dTable As DataTable
        Dim sSpName As String = "spFlashCardSelAll"
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dSet As DataSet
        dSet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, sSpName)
        dTable = dSet.Tables(0)
        Return dTable
    End Function

    Public Overridable Function ListBySuggestedActionID(ByVal aSuggestedActionID As Int32) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "spFlashCardSelBySuggestedActionID"
        Dim sqlSuggestedActionID As SqlParameter = New SqlParameter("@SuggestedActionID", SqlDbType.Int)
        sqlSuggestedActionID.Value = aSuggestedActionID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sqlSuggestedActionID)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

    Public Overridable Function ListByExplanationID(ByVal aExplanationID As Int32) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "spFlashCardSelByExplanationID"
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        sqlExplanationID.Value = aExplanationID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sqlExplanationID)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

    Public Overridable Function ListByDealersUpCardAndPlayersHand(ByVal aDealersUpCard As String, ByVal aPlayersHand As String) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "spFlashCardSelByDealersUpCardAndPlayersHand"
        Dim sqlDealersUpCard As SqlParameter = New SqlParameter("@DealersUpCard", SqlDbType.NVarChar)
        Dim sqlPlayersHand As SqlParameter = New SqlParameter("@PlayersHand", SqlDbType.NVarChar)
        sqlDealersUpCard.Value = aDealersUpCard
        sqlPlayersHand.Value = aPlayersHand
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sqlDealersUpCard, sqlPlayersHand)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

    Public Overridable Function ListByFlashCardID(ByVal aFlashCardID As Int32) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "spFlashCardSelByFlashCardID"
        Dim sqlFlashCardID As SqlParameter = New SqlParameter("@FlashCardID", SqlDbType.Int)
        sqlFlashCardID.Value = aFlashCardID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sqlFlashCardID)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

    Public Overridable Function DeleteByDealersUpCardAndPlayersHand(ByVal aDealersUpCard As String, ByVal aPlayersHand As String) As Integer
        Dim spName As String = "spFlashCardDelByDealersUpCardAndPlayersHand"
        Dim sqlDealersUpCard As SqlParameter = New SqlParameter("@DealersUpCard", SqlDbType.NVarChar)
        Dim sqlPlayersHand As SqlParameter = New SqlParameter("@PlayersHand", SqlDbType.NVarChar)
        sqlDealersUpCard.Value = aDealersUpCard
        sqlPlayersHand.Value = aPlayersHand
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, spName, sqlDealersUpCard, sqlPlayersHand)
        Return iRet
    End Function

    Public Overridable Function DeleteByFlashCardID(ByVal aFlashCardID As Int32) As Integer
        Dim spName As String = "spFlashCardDelByFlashCardID"
        Dim sqlFlashCardID As SqlParameter = New SqlParameter("@FlashCardID", SqlDbType.Int)
        sqlFlashCardID.Value = aFlashCardID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, spName, sqlFlashCardID)
        Return iRet
    End Function

    Public Overridable Function DeleteBySuggestedActionID(ByVal aSuggestedActionID As Int32) As Integer
        Dim spName As String = "spFlashCardDelBySuggestedActionID"
        Dim sqlSuggestedActionID As SqlParameter = New SqlParameter("@SuggestedActionID", SqlDbType.Int)
        sqlSuggestedActionID.Value = aSuggestedActionID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, spName, sqlSuggestedActionID)
        Return iRet
    End Function

    Public Overridable Function DeleteByExplanationID(ByVal aExplanationID As Int32) As Integer
        Dim spName As String = "spFlashCardDelByExplanationID"
        Dim sqlExplanationID As SqlParameter = New SqlParameter("@ExplanationID", SqlDbType.Int)
        sqlExplanationID.Value = aExplanationID
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim iRet As Integer
        iRet = SqlHelper.ExecuteScalarAsInt(sConn, CommandType.StoredProcedure, spName, sqlExplanationID)
        Return iRet
    End Function

    Public Overridable Function ListDynamic(ByVal aWhereCondition As String, ByVal aOrderByExpression As String) As DataTable
        Dim dtRet As DataTable
        Dim spName As String = "[dbo].[spFlashCardSelDyn]"
        Dim sWhere As SqlParameter = New SqlParameter("@WhereCondition", SqlDbType.NVarChar, 500)
        Dim sOrder As SqlParameter = New SqlParameter("@OrderByExpression", SqlDbType.NVarChar, 250)
        sWhere.Value = aWhereCondition
        sOrder.Value = aOrderByExpression
        Dim sConn As String = TheSettings.SQLConnectionString
        Dim dsRet As DataSet
        dsRet = SqlHelper.ExecuteDataset(sConn, CommandType.StoredProcedure, spName, sWhere, sOrder)
        dtRet = dsRet.Tables(0)
        Return dtRet
    End Function

#End Region

End Class











